<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
/*ini_set("memory_limit", "200M");
  mysql_connect("host=localhost dbname=comld  user=root  password=root")
   or die('Could not connect:'.mysql_last_error());
*/
$db_name="comld";  
 
$table_name="comld";  
 
$connection= @mysql_connect("localhost","root","root") or die(mysql_error());  
 
$db= @mysql_select_db($db_name,$connection) or die (mysql_error()); 
$stime =  date("Y-m-d",strtotime("-46 day"));
$etime =  date("Y-m-d",strtotime("-1 day"));
 
$logdate =  mysql_query("SELECT DISTINCT whatdate FROM comld  WHERE whatdate BETWEEN '$stime' AND '$etime'");

while($everylogdate = mysql_fetch_array($logdate))
{
     //游戏总注册人数
    $loginPersonNum_query = mysql_query("SELECT count(DISTINCT deviceid) FROM comld where Jailbreak = '0'");

    $loginPersonNum = mysql_fetch_array($loginPersonNum_query);

     //日均活跃人数 
    $activePesonrNum_query = mysql_query("select(SELECT count(DISTINCT deviceid)  FROM comld where Jailbreak = '0')/(SELECT count( DISTINCT whatdate )FROM comld)");
    $activePesonrNum = mysql_fetch_array($activePesonrNum_query);

    //日均活跃人次 activePesonrTime 一个人可能多次
    $activePesonrTime_query = mysql_query("select (SELECT count(deviceid)  FROM comld where Jailbreak = '0' )/(SELECT count( DISTINCT whatdate )FROM comld)");
    $activePesonrTime = mysql_fetch_array($activePesonrTime_query);

    //日均人均打开次数  //DISTINCT deviceid
    $totalTodayGameTime_query = mysql_query("SELECT '$activePesonrTime[0]'/'$activePesonrNum[0]'");
    $totalTodayGameTime = mysql_fetch_array($totalTodayGameTime_query);
    //日均游戏时间
    $totalDayTotalTime_query = mysql_query("SELECT avg(fGameTimeToday)  FROM comld where Jailbreak = '0'");
    $totalDayTotalTime = mysql_fetch_array($totalDayTotalTime_query);

     //日均金钱获得
    $totalDayGetMoney_query = mysql_query("SELECT avg(nGoldGainFromGameToday) FROM comld where Jailbreak = '0'");
    $totalDayGetMoney = mysql_fetch_array($totalDayGetMoney_query);

    //日均IAP金钱获得
    //$totalDayGetIAPMoney_query = mysql_query("SELECT avg(TotalGoldGet) FROM comld  where Jailbreak = '0'");
    //$totalDayGetIAPMoney = mysql_fetch_array($totalDayGetIAPMoney_query);

    //日均充值

    $totalDayRecharge_query = mysql_query("SELECT avg(nGoldGainFromIAPToday) FROM comld where Jailbreak = '0'");
    $totalDayRecharge = mysql_fetch_array($totalDayRecharge_query);
    
    //日均消费totalDayUsedMoney

    $totalDayUsedMoney_query = mysql_query("SELECT avg(nGoldConsumeToday)  FROM  comld where Jailbreak = '0'");
    $totalDayUsedMoney = mysql_fetch_array($totalDayUsedMoney_query);
     
    //日均注册人数
    $dayLoginPersonNum_query = mysql_query("select(SELECT count(DISTINCT deviceid) FROM comld where Jailbreak = '0')/(SELECT count( DISTINCT whatdate )FROM comld where Jailbreak = '0')");

    $dayLoginPersonNum = mysql_fetch_array($dayLoginPersonNum_query);

    //totalDayNewusers 每日新注册 DISTINCT
    $totalDayNewusers_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  comld  where FirstLoginTime = '$everylogdate[whatdate]' and  Jailbreak = '0'");
    $totalDayNewusers = mysql_fetch_array($totalDayNewusers_query);

    //DayActivePesonrNum  每日活跃人数  //  日均TodayGameTime 活跃人数 今日的
    $dayActivePesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM comld  where whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0' and whatdate <> FirstLoginTime");
    $dayActivePesonrNum = mysql_fetch_array($dayActivePesonrNum_query);

    //dayActivePesonrTime 每日活跃人次
    $dayActivePesonrTime_query = mysql_query("SELECT sum( nStartGameToday +1 ) FROM comld WHERE Jailbreak = '0' and whatdate ='$everylogdate[whatdate]' and whatdate <> FirstLoginTime");
    $dayActivePesonrTime = mysql_fetch_array($dayActivePesonrTime_query);
      //weekOneLandPesonrNum 过去7日内1次登录用户数
     $weekOneLandPesonrNum_query = mysql_query("  SELECT DISTINCT deviceid, whatdate
        FROM comld
        WHERE Jailbreak = '0'  and whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND date_sub( '$everylogdate[whatdate]', INTERVAL 1
        DAY )
        GROUP BY deviceid
        HAVING count( 1 ) >0
       ");
     $weekOneLandPesonrNum = mysql_num_rows($weekOneLandPesonrNum_query);

     //weekActivePesonrNum   过去7日内2次登录用户数 每周活跃人数  SELECT * FROM comld   where date_sub( whatdate, INTERVAL 7 DAY ) <= whatdate( '$everylogdate[whatdate]' )
    $weekActivePesonrNum_query = mysql_query("  SELECT DISTINCT deviceid, whatdate
        FROM comld
        WHERE Jailbreak = '0'  and whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND date_sub( '$everylogdate[whatdate]', INTERVAL 1
        DAY )
        GROUP BY deviceid
        HAVING count( 1 ) >1
       ");
    //$weekActivePesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  comld  where whatdate_add(whatdate,interval 2 day)   and date_sub( whatdate, INTERVAL 7 DAY ) <= whatdate( '$everylogdate[whatdate]' )  and  Jailbreak = '0'");
    $weekActivePesonrNum = mysql_num_rows($weekActivePesonrNum_query);

    //weekLoyalPesonrNum  过去7日内3次登录用户数 每周忠诚用户人数
    $weekLoyalPesonrNum_query = mysql_query("SELECT DISTINCT deviceid, whatdate
        FROM comld
        WHERE Jailbreak = '0'  and   whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND date_sub( '$everylogdate[whatdate]', INTERVAL 1
        DAY )
        GROUP BY deviceid
        HAVING count( 1 ) >2
        ");
   $weekLoyalPesonrNum = mysql_num_rows($weekLoyalPesonrNum_query);

    //weekCorePesonrNum   过去7日内4次用户数 每周核心用户人数
    $weekCorePesonrNum_query = mysql_query("SELECT DISTINCT deviceid, whatdate
        FROM comld
        WHERE Jailbreak = '0'  and   whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND date_sub( '$everylogdate[whatdate]', INTERVAL 1
        DAY )
        GROUP BY deviceid
        HAVING count( 1 ) >3
        ");
    $weekCorePesonrNum = mysql_num_rows($weekCorePesonrNum_query);

    // 挂网等雇佣用户数 hirePesonrNum
    //$hirePesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and hireoutselftimes >0 and  Jailbreak = '0'");
   // $hirePesonrNum = mysql_fetch_array($hirePesonrNum_query);

    //今日均人均游戏时间
    $dayTotalTime_query = mysql_query("select (SELECT sum(fGameTimeToday)  FROM comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')/(SELECT count(DISTINCT deviceid)  FROM comld  where whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0' and whatdate <> FirstLoginTime)");
    $dayTotalTime = mysql_fetch_array($dayTotalTime_query);

    //今日均消费金钱 DayUsedMoney 
    $dayUsedMoney_query = mysql_query("select (SELECT sum(nGoldConsumeToday)  FROM  comld   where whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')/('$dayActivePesonrNum[0]')");
    $dayUsedMoney = mysql_fetch_array($dayUsedMoney_query);

    //weekPayPesonrNum 周付费用户数 SELECT count( DISTINCT deviceid )  
    $weekPayPesonrNum_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM comld
        WHERE nGoldGainFromIAPToday >0
        AND whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND jailbreak = '0'");
    $weekPayPesonrNum = mysql_fetch_array($weekPayPesonrNum_query);
    //dayIAPGetMoney  今日人均 IAP 获得金钱
    $dayIAPGetMoney_query = mysql_query("select (select sum(nGoldGainFromIAPToday) from comld where whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')/('$dayActivePesonrNum[0]')");
    $dayIAPGetMoney = mysql_fetch_array($dayIAPGetMoney_query);
    //avgDayMoney  今日人均获得金钱
    $avgDayMoney_query = mysql_query("select (SELECT sum(nGoldGainFromGameToday)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')/(SELECT count(deviceid)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')");
    $avgDayMoney = mysql_fetch_array($avgDayMoney_query);
    
    //dayNowMoney  今日人均现有金钱
    $dayNowMoney_query = mysql_query("select (SELECT sum(totalnGoldNow)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0')/(SELECT count(deviceid)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0' )");
    $dayNowMoney = mysql_fetch_array($dayNowMoney_query);

/*
    //最后退出 10界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen10Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 10  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen10Num = mysql_fetch_array($Lastloginscreen10Num_query);

        //最后退出 21界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen21Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 21  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen21Num = mysql_fetch_array($Lastloginscreen21Num_query);

        //最后退出 22界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen22Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 22  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen22Num = mysql_fetch_array($Lastloginscreen22Num_query);
        //最后退出 23界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen23Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 23  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen23Num = mysql_fetch_array($Lastloginscreen23Num_query);
        //最后退出 24界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen24m_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 24  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen24Num = mysql_fetch_array($Lastloginscreen24m_query);
        //最后退出 31界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen31Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 31  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen31Num = mysql_fetch_array($Lastloginscreen31Num_query);
        //最后退出 41界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen41Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 41  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen41Num = mysql_fetch_array($Lastloginscreen41Num_query);
        //最后退出 42界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen42Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 42  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen42Num = mysql_fetch_array($Lastloginscreen42Num_query);
        //最后退出 50界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen50Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 50  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen50Num = mysql_fetch_array($Lastloginscreen50Num_query);
        //最后退出 60界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen60Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 60  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen60Num = mysql_fetch_array($Lastloginscreen60Num_query);
        //最后退出 71界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen71Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 71  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen71Num = mysql_fetch_array($Lastloginscreen71Num_query);
        //最后退出 72界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen72Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 72  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen72Num = mysql_fetch_array($Lastloginscreen72Num_query);
        //最后退出 73界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen73Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 73  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen73Num = mysql_fetch_array($Lastloginscreen73Num_query);
        //最后退出 80界面 人数统计 Lastloginscreen10Num
    $Lastloginscreen80Num_query = mysql_query("SELECT count(distinct deviceid) FROM comld where Jailbreak = '0' and UILastId = 80  and whatdate ='$everylogdate[whatdate]'");
    $Lastloginscreen80Num = mysql_fetch_array($Lastloginscreen80Num_query);
*/
/*
 
    // p1等级分布 (1,2,....)
    $whatdate = array('1' => array($p1whatdate1Count, $whatdate1), array($p1whatdate2Count, $whatdate2), array($p1whatdate3Count, $whatdate3), array($p1whatdate4Count, $whatdate4), array($p1whatdate5Count, $whatdate5), array($p1whatdate6Count, $whatdate6), array($p1whatdate7Count, $whatdate7), array($p1whatdate8Count, $whatdate8), array($p1whatdate9Count, $whatdate9), array($p1whatdate10Count, $whatdate10), array($p1whatdate11Count, $whatdate11), array($p1whatdate12Count, $whatdate12), array($p1whatdate13Count, $whatdate13), array($p1whatdate14Count, $whatdate14), array($p1whatdate15Count, $whatdate15), array($p1whatdate16Count, $whatdate16), array($p1whatdate17Count, $whatdate17), array($p1whatdate18Count, $whatdate18), array($p1whatdate19Count, $whatdate19), array($p1whatdate20Count, $whatdate20), array($p1whatdate21Count, $whatdate21));
    // $whatdate1[] = 
    $whatdate1_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =1
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =1
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate1_a = mysql_fetch_array($whatdate1_query);
    $whatdate1 = $whatdate1_a[0];
    $p1whatdate1Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =1
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =1
AND a.Jailbreak = '0'
");
    $p1whatdate1Count_a = mysql_fetch_array($p1whatdate1Count_query);
    $p1whatdate1Count = $p1whatdate1Count_a[0];
    $whatdate2_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =2
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =2
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate2_a = mysql_fetch_array($whatdate2_query);
    $whatdate2 = $whatdate2_a[0];
    $p1whatdate2Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =2
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =2
AND a.Jailbreak = '0'");
    $p1whatdate2Count_a = mysql_fetch_array($p1whatdate2Count_query);
    $p1whatdate2Count = $p1whatdate2Count_a[0];
    $whatdate3_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =3
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =3
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate3_a = mysql_fetch_array($whatdate3_query);
    $whatdate3 = $whatdate3_a[0];
    $p1whatdate3Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =3
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =3
AND a.Jailbreak = '0'");
    $p1whatdate3Count_a = mysql_fetch_array($p1whatdate3Count_query);
    $p1whatdate3Count = $p1whatdate3Count_a[0];
    $whatdate4_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =4
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =4
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate4_a = mysql_fetch_array($whatdate4_query);
    $whatdate4 = $whatdate4_a[0];
    $p1whatdate4Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =4
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =4
AND a.Jailbreak = '0'");
    $p1whatdate4Count_a = mysql_fetch_array($p1whatdate4Count_query);
    $p1whatdate4Count = $p1whatdate4Count_a[0];
    $whatdate5_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =5
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =5
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate5_a = mysql_fetch_array($whatdate5_query);
    $whatdate5 = $whatdate5_a[0];
    $p1whatdate5Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =5
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =5
AND a.Jailbreak = '0'");
    $p1whatdate5Count_a = mysql_fetch_array($p1whatdate5Count_query);
    $p1whatdate5Count = $p1whatdate5Count_a[0];
    $whatdate6_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =6
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =6
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate6_a = mysql_fetch_array($whatdate6_query);
    $whatdate6 = $whatdate6_a[0];
    $p1whatdate6Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =6
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =6
AND a.Jailbreak = '0'");
    $p1whatdate6Count_a = mysql_fetch_array($p1whatdate6Count_query);
    $p1whatdate6Count = $p1whatdate6Count_a[0];
    $whatdate7_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =7
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =7
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate7_a = mysql_fetch_array($whatdate7_query);
    $whatdate7 = $whatdate7_a[0];
    $p1whatdate7Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =7
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =7
AND a.Jailbreak = '0'");
    $p1whatdate7Count_a = mysql_fetch_array($p1whatdate7Count_query);
    $p1whatdate7Count = $p1whatdate7Count_a[0];
    $whatdate8_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =8
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =8
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate8_a = mysql_fetch_array($whatdate8_query);
    $whatdate8 = $whatdate8_a[0];
    $p1whatdate8Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max(id)
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =8
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate(a.whatdate)
AND a.Level =8
AND a.Jailbreak = '0'");
    $p1whatdate8Count_a = mysql_fetch_array($p1whatdate8Count_query);
    $p1whatdate8Count = $p1whatdate8Count_a[0];
    $whatdate9_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =9
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =9
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate9_a = mysql_fetch_array($whatdate9_query);
    $whatdate9 = $whatdate9_a[0];
    $p1whatdate9Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =9
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =9
AND a.Jailbreak = '0'");
    $p1whatdate9Count_a = mysql_fetch_array($p1whatdate9Count_query);
    $p1whatdate9Count = $p1whatdate9Count_a[0];
    $whatdate10_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =10
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =10
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate10_a = mysql_fetch_array($whatdate10_query);
    $whatdate10 = $whatdate10_a[0];
    $p1whatdate10Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level =10
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level =10
AND a.Jailbreak = '0'");
    $p1whatdate10Count_a = mysql_fetch_array($p1whatdate10Count_query);
    $p1whatdate10Count = $p1whatdate10Count_a[0];
    $whatdate11_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 11 and 15
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 11 and 15
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')
");
    $whatdate11_a = mysql_fetch_array($whatdate11_query);
    $whatdate11 = $whatdate11_a[0];
    $p1whatdate11Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 11 and 15
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 11 and 15
AND a.Jailbreak = '0'");
    $p1whatdate11Count_a = mysql_fetch_array($p1whatdate11Count_query);
    $p1whatdate11Count = $p1whatdate11Count_a[0];
    $whatdate12_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 16 and 20
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 16 and 20
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%'
)");
    $whatdate12_a = mysql_fetch_array($whatdate12_query);
    $whatdate12 = $whatdate12_a[0];
    $p1whatdate12Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 16 and 20
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 16 and 20
AND a.Jailbreak = '0'");
    $p1whatdate12Count_a = mysql_fetch_array($p1whatdate12Count_query);
    $p1whatdate12Count = $p1whatdate12Count_a[0];
    $whatdate13_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 21 and 25
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 21 and 25
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate13_a = mysql_fetch_array($whatdate13_query);
    $whatdate13 = $whatdate13_a[0];
    $p1whatdate13Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 21 and 25
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 21 and 25
AND a.Jailbreak = '0'");
    $p1whatdate13Count_a = mysql_fetch_array($p1whatdate13Count_query);
    $p1whatdate13Count = $p1whatdate13Count_a[0];
    $whatdate14_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 26 and 30
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 26 and 30
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate14_a = mysql_fetch_array($whatdate14_query);
    $whatdate14 = $whatdate14_a[0];
    $p1whatdate14Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 26 and 30
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 26 and 30
AND a.Jailbreak = '0'");
    $p1whatdate14Count_a = mysql_fetch_array($p1whatdate14Count_query);
    $p1whatdate14Count = $p1whatdate14Count_a[0];
    $whatdate15_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 31 and 40
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 31 and 40
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate15_a = mysql_fetch_array($whatdate15_query);
    $whatdate15 = $whatdate15_a[0];
    $p1whatdate15Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 31 and 40
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 31 and 40
AND a.Jailbreak = '0'");
    $p1whatdate15Count_a = mysql_fetch_array($p1whatdate15Count_query);
    $p1whatdate15Count = $p1whatdate15Count_a[0];
    $whatdate16_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 41 and 50
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 41 and 50
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate16_a = mysql_fetch_array($whatdate16_query);
    $whatdate16 = $whatdate16_a[0];
    $p1whatdate16Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 41 and 50
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 41 and 50
AND a.Jailbreak = '0'");
    $p1whatdate16Count_a = mysql_fetch_array($p1whatdate16Count_query);
    $p1whatdate16Count = $p1whatdate16Count_a[0];
    $whatdate17_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 51 and 60
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 51 and 60
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate17_a = mysql_fetch_array($whatdate17_query);
    $whatdate17 = $whatdate17_a[0];
    $p1whatdate17Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 51 and 60
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 51 and 60
AND a.Jailbreak = '0'");
    $p1whatdate17Count_a = mysql_fetch_array($p1whatdate17Count_query);
    $p1whatdate17Count = $p1whatdate17Count_a[0];
    $whatdate18_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 61 and 70
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 61 and 70
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate18_a = mysql_fetch_array($whatdate18_query);
    $whatdate18 = $whatdate18_a[0];
    $p1whatdate18Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 61 and 70
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 61 and 70
AND a.Jailbreak = '0'");
    $p1whatdate18Count_a = mysql_fetch_array($p1whatdate18Count_query);
    $p1whatdate18Count = $p1whatdate18Count_a[0];
    $whatdate19_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 71 and 80
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 71 and 80
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate19_a = mysql_fetch_array($whatdate19_query);
    $whatdate19 = $whatdate19_a[0];
    $p1whatdate19Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 71 and 80
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 71 and 80
AND a.Jailbreak = '0'");
    $p1whatdate19Count_a = mysql_fetch_array($p1whatdate19Count_query);
    $p1whatdate19Count = $p1whatdate19Count_a[0];
    $whatdate20_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 81 and 90
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 81 and 90
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate20_a = mysql_fetch_array($whatdate20_query);
    $whatdate20 = $whatdate20_a[0];
    $p1whatdate20Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 81 and 90
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 81 and 90
AND a.Jailbreak = '0'");
    $p1whatdate20Count_a = mysql_fetch_array($p1whatdate20Count_query);
    $p1whatdate20Count = $p1whatdate20Count_a[0];
    $whatdate21_query = mysql_query("SELECT concat( (
(

SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 91 and 100
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 91 and 100
AND a.Jailbreak = '0' ) / (
SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Jailbreak = '0' )
) *100, '%')");
    $whatdate21_a = mysql_fetch_array($whatdate21_query);
    $whatdate21 = $whatdate21_a[0];
    $p1whatdate21Count_query = mysql_query("SELECT count( DISTINCT deviceid )
FROM comld a
WHERE id = (
SELECT max( id )
FROM comld
WHERE `deviceid` = a.`deviceid`
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( whatdate )
AND Level between 91 and 100
AND Jailbreak = '0' )
AND date_sub( '$everylogdate[whatdate]', INTERVAL 7
DAY ) <= whatdate( a.whatdate )
AND a.Level between 91 and 100
AND a.Jailbreak = '0'");
    $p1whatdate21Count_a = mysql_fetch_array($p1whatdate21Count_query);
    $p1whatdate21Count = $p1whatdate21Count_a[0];
    $Level = array(json_encode($whatdate));//等级分布  */

        //newPayPesonrNum  新增付费人数
    /*SELECT count( DISTINCT deviceid )
FROM comld a
WHERE nGoldGainFromIAPToday >0
AND whatdate = '$everylogdate[whatdate]'
AND Jailbreak = '0'
AND NOT
EXISTS (

SELECT DISTINCT deviceid
FROM comld
WHERE nGoldGainFromIAPToday >0
AND whatdate < '$everylogdate[whatdate]'
AND Jailbreak = '0'
AND a.deviceid = deviceid
)
*/
    $newPayPesonrNum_query = mysql_query("SELECT DISTINCT a.deviceid
        FROM (

        SELECT DISTINCT a.deviceid
        FROM comld a
        WHERE a.nGoldGainFromIAPToday >0
        AND a.Jailbreak =  '0'
        AND a.whatdate = DATE_SUB(  '$everylogdate[whatdate]', INTERVAL 0 
        DAY )
        )a
        LEFT JOIN (

        SELECT DISTINCT deviceid
        FROM comld
        WHERE Jailbreak =  '0'
        AND whatdate
        BETWEEN DATE_SUB(  '$everylogdate[whatdate]', INTERVAL 360 
        DAY ) 
        AND DATE_SUB(  '$everylogdate[whatdate]', INTERVAL 1 
        DAY ) 
        AND nGoldGainFromIAPToday =0
        )b ON a.deviceid = b.deviceid
        WHERE b.deviceid IS NOT NULL");
    $newPayPesonrNum = mysql_num_rows($newPayPesonrNum_query);
    //今日付费次数 paytimes
    $paytimes_query = mysql_query("SELECT sum(_499cents1 + _499cents2 + _299cents1 + _199cents1 + _099cents1 +_099cents2 + _999cents1 + _999cents2 + _1999cents1 + _1999cents2 + _9999cents1 + _9999cents2 + _4999cents1 + _4999cents2 + _199cents2 + _299cents2)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and  Jailbreak = '0'");
    $paytimes = mysql_fetch_array($paytimes_query);
    //今日付费用户数 PayPesonrNum
    $PayPesonrNum_query = mysql_query("SELECT count(DISTINCT deviceid)  FROM  comld  where  whatdate ='$everylogdate[whatdate]' and nGoldGainFromIAPToday >0 and  Jailbreak = '0'");
    $PayPesonrNum = mysql_fetch_array($PayPesonrNum_query);

     $iap1_query = mysql_query(" SELECT sum(_099cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0' ");
    $iap1 = mysql_fetch_array($iap1_query);
   /* }
      var_dump($iap1_to[0]);*/
    //iap2
    $iap2_query = mysql_query("SELECT sum(_499cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
    $iap2 = mysql_fetch_array($iap2_query);
    //iap3
    $iap3_query = mysql_query("SELECT sum(_499cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
    $iap3 = mysql_fetch_array($iap3_query);
    //iap4
    $iap4_query = mysql_query("SELECT sum(_299cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
    $iap4 = mysql_fetch_array($iap4_query);
    //iap5
    $iap5_query = mysql_query("SELECT sum(_199cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
    $iap5 = mysql_fetch_array($iap5_query);
     // iap6
     $iap6_query = mysql_query("SELECT sum(_9999cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap6 = mysql_fetch_array($iap6_query);
     // iap7
     $iap7_query = mysql_query("SELECT sum(_999cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap7 = mysql_fetch_array($iap7_query);
     // iap8
     $iap8_query = mysql_query("SELECT sum(_999cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap8 = mysql_fetch_array($iap8_query);
     // iap9
     $iap9_query = mysql_query("SELECT sum(_1999cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap9 = mysql_fetch_array($iap9_query);
     // iap10
     $iap10_query = mysql_query("SELECT sum(_9999cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap10 = mysql_fetch_array($iap10_query);
     // iap11
     $iap11_query = mysql_query("SELECT sum(_4999cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap11 = mysql_fetch_array($iap11_query);
     // iap12
     $iap12_query = mysql_query("SELECT sum(_4999cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap12 = mysql_fetch_array($iap12_query);
     // iap13
     $iap13_query = mysql_query("SELECT sum(_199cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap13 = mysql_fetch_array($iap13_query);
     // iap14
     $iap14_query = mysql_query("SELECT sum(_299cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap14 = mysql_fetch_array($iap14_query);
     // iap15
     $iap15_query = mysql_query("SELECT sum(_099cents2) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap15 = mysql_fetch_array($iap15_query);
     // iap16
     $iap16_query = mysql_query("SELECT sum(_1999cents1) FROM  comld  where  whatdate ='$everylogdate[whatdate]' and Jailbreak = '0'");
     $iap16 = mysql_fetch_array($iap16_query);

     //WeekNewPayPesonrNum 过去7日内新增注册用户数
     $WeekNewPayPesonrNum_query = mysql_query("SELECT count( DISTINCT deviceid )
        FROM comld
        WHERE FirstLoginTime
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0'");
     $WeekNewPayPesonrNum = mysql_fetch_array($WeekNewPayPesonrNum_query);
     //MonthLandTwicePesonrNum 过去30日内2次登录用户数
        $MonthLandTwicePesonrNum_query = mysql_query("SELECT DISTINCT deviceid, whatdate
        FROM comld
        WHERE Jailbreak = '0'
        AND whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 30
        DAY )
        AND date_sub( '$everylogdate[whatdate]', INTERVAL 1
        DAY )
        GROUP BY deviceid
        HAVING count( 1 ) >1 ");
     $MonthLandTwicePesonrNum = mysql_num_rows($MonthLandTwicePesonrNum_query);
     //WeekPayRechargeNum 周付费用户充值笔数
             $WeekPayRechargeNum_query = mysql_query("SELECT sum(_499cents1 + _499cents2 + _299cents1 + _199cents1 + _099cents1 +_099cents2 + _999cents1 + _999cents2 + _1999cents1 + _1999cents2 + _9999cents1 + _9999cents2 + _4999cents1 + _4999cents2 + _199cents2 + _299cents2 )
        FROM comld
        WHERE whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0'
        ");
     $WeekPayRechargeNum = mysql_fetch_array($WeekPayRechargeNum_query);

    //dayRechargeNum  今日人均充值笔数
   $dayRechargeNum_query = mysql_query("select '$paytimes[0]'/'$PayPesonrNum[0]'");
   $dayRechargeNum = mysql_fetch_array($dayRechargeNum_query);
   //weekPayARPU 周付费用户ARPU值 =周付费总额/周付费人数
    $weekPayARPU_query = mysql_query("SELECT (
        SELECT sum( _499cents2*499  +_099cents2 *99 + _999cents2 *999 + _1999cents2 *1999 + _9999cents2 *9999  + _4999cents2*4999 + _199cents2 *199+ _299cents2*299 +_499cents1*499  +_099cents1 *99 + _999cents1 *999 + _1999cents1 *1999 + _9999cents1 *9999  + _4999cents1*4999 + _199cents1 *199+ _299cents1*299)
        FROM comld
        WHERE whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0'
        ) / (
        '$weekPayPesonrNum[0]' )");

    $weekPayARPU = mysql_fetch_array($weekPayARPU_query); 
    
    //weekActiveARPU 周活跃用户ARPU值
    $weekActiveARPU_query = mysql_query("SELECT (
        SELECT sum( _499cents2*499  +_099cents2 *99 + _999cents2 *999 + _1999cents2 *1999 + _9999cents2 *9999  + _4999cents2*4999 + _199cents2 *199+ _299cents2*299 +_499cents1*499  +_099cents1 *99 + _999cents1 *999 + _1999cents1 *1999 + _9999cents1 *9999  + _4999cents1*4999 + _199cents1 *199+ _299cents1*299)
        FROM comld
        WHERE whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0'
        ) / ($weekActivePesonrNum) ");
   $weekActiveARPU = mysql_fetch_array($weekActiveARPU_query);
   
       //weekLogARPU 周登陆用户ARPU值  = 周付费用户/周登陆人数(活跃用户+新用户)  
   $weekLogARPU_query = mysql_query("SELECT (
        SELECT sum( _499cents2*499  +_099cents2 *99 + _999cents2 *999 + _1999cents2 *1999 + _9999cents2 *9999  + _4999cents2*4999 + _199cents2 *199+ _299cents2*299 +_499cents1*499  +_099cents1 *99 + _999cents1 *999 + _1999cents1 *1999 + _9999cents1 *9999  + _4999cents1*4999 + _199cents1 *199+ _299cents1*299)
        FROM comld
        WHERE whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0'
        ) / (
        SELECT count( DISTINCT deviceid )
        FROM comld
        WHERE whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]'
        AND Jailbreak = '0' ) ");
      $weekLogARPU = mysql_fetch_array($weekLogARPU_query);
      //weekWastageRate  周活跃用户流失率 上周活跃用户在本周没有登陆过游戏的用户数，除以上周的活跃人数。
      $weekWastageRate_query = mysql_query("SELECT concat(round( (
        SELECT (
        SELECT count( a.deviceid )
        FROM weekActive a
        WHERE a.whatdate = date_sub('$everylogdate[whatdate]',interval 7 day)  
        AND a.deviceid NOT
        IN (
        SELECT DISTINCT deviceid
        FROM comld
        WHERE Jailbreak = '0'
        AND whatdate
        BETWEEN date_sub('$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]' )
        ) / (
        SELECT count( 1 )
        FROM weekActive
        WHERE whatdate = date_sub('$everylogdate[whatdate]',interval 7 day))
        ) *100,2), '%'
        )  ");
     $weekWastageRate = mysql_fetch_array($weekWastageRate_query); 
     //weekPayRate  周活跃用户付费率 周付费用户数除以周活跃人数
    //$weekPayRate_query = mysql_query("select '$weekPayPesonrNum[0]'/'$weekActivePesonrNum[0]'");
    $weekPayRate_query = mysql_query("SELECT concat(round( '$weekPayPesonrNum[0]'/  '$weekActivePesonrNum' *100,2), '%' ) ");
    $weekPayRate = mysql_fetch_array($weekPayRate_query);
    //weekLogPayRate周登陆用户付费率 周付费用户数除以周登陆人数
    $weekLogPayRate_query = mysql_query("SELECT concat(round( '$weekPayPesonrNum[0]'/  '$weekOneLandPesonrNum' *100,2), '%' ) ");
    $weekLogPayRate = mysql_fetch_array($weekLogPayRate_query);
       //weekPayWastageRate  周付费用户流失率 上周有付费行为而本周7天未登陆的用户数除以上周的付费用户数  
    $weekPayWastageRate_query = mysql_query("SELECT concat( round((
        SELECT (
        SELECT count( a.deviceid )
        FROM weekPay a
        WHERE a.whatdate = date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND a.deviceid NOT
        IN (

        SELECT DISTINCT deviceid
        FROM comld
        WHERE Jailbreak = '0'
        AND whatdate
        BETWEEN date_sub( '$everylogdate[whatdate]', INTERVAL 7
        DAY )
        AND '$everylogdate[whatdate]' )
        ) / (
        SELECT count( 1 )
        FROM weekPay
        WHERE whatdate =  date_sub('$everylogdate[whatdate]',interval 7 day) )
        ) *100,2), '%'
        ) ");
     $weekPayWastageRate = mysql_fetch_array($weekPayWastageRate_query);
     //周付费用户人均充值笔数
     $weekPayPesonrTime_query = mysql_query("SELECT '$WeekPayRechargeNum[0]'/'$weekPayPesonrNum[0]'");
     $weekPayPesonrTime = mysql_fetch_array($weekPayPesonrTime_query);

   
 $sql="REPLACE INTO report_nojailbreak (logdate,loginPersonNum,activePesonrNum,activePesonrTime,totalDayTotalTime,
                                        totalDayGetMoney,totalDayRecharge,totalDayUsedMoney,dayLoginPersonNum,
                                        totalDayNewusers,dayActivePesonrNum,dayActivePesonrTime,weekActivePesonrNum,weekLoyalPesonrNum,weekCorePesonrNum,
                                        hirePesonrNum,dayTotalTime,dayUsedMoney,weekPayPesonrNum,dayIAPGetMoney,
                                        avgDayMoney,dayNowMoney,
                                        Lastloginscreen10Num,Lastloginscreen21Num,Lastloginscreen22Num,Lastloginscreen23Num,Lastloginscreen24Num,
                                        Lastloginscreen31Num,Lastloginscreen41Num,Lastloginscreen42Num,Lastloginscreen50Num,Lastloginscreen60Num,
                                        Lastloginscreen71Num,Lastloginscreen72Num,Lastloginscreen73Num,Lastloginscreen80Num,
                                        weekPayARPU,weekActiveARPU,weekLogARPU,weekWastageRate,weekPayRate,weekLogPayRate,weekPayWastageRate,
                                        weekPayPesonrTime,playerLevel,newPayPesonrNum,paytimes,PayPesonrNum,
                                        iap1,iap2,iap3,iap4,iap5,iap6,iap7,iap8,iap9,iap10,iap11,iap12,iap13,iap14,iap15,iap16,totalDayPlayTime,
                                        weekOneLandPesonrNum,WeekNewPayPesonrNum,MonthLandTwicePesonrNum,WeekPayRechargeNum,dayRechargeNum) 
                  VALUES('$everylogdate[whatdate]','$loginPersonNum[0]','$activePesonrNum[0]','$activePesonrTime[0]','$totalDayTotalTime[0]',
                         '$totalDayGetMoney[0]','$totalDayRecharge[0]','$totalDayUsedMoney[0]','$dayLoginPersonNum[0]',
                         '$totalDayNewusers[0]','$dayActivePesonrNum[0]','$dayActivePesonrTime[0]','$weekActivePesonrNum','$weekLoyalPesonrNum','$weekCorePesonrNum',
                          '$hirePesonrNum[0]','$dayTotalTime[0]','$dayUsedMoney[0]','$weekPayPesonrNum[0]','$dayIAPGetMoney[0]',
                          '$avgDayMoney[0]','$dayNowMoney[0]',
                          '$Lastloginscreen10Num[0]','$Lastloginscreen21Num[0]','$Lastloginscreen22Num[0]','$Lastloginscreen23Num[0]','$Lastloginscreen24Num[0]',
                          '$Lastloginscreen31Num[0]','$Lastloginscreen41Num[0]','$Lastloginscreen42Num[0]','$Lastloginscreen50Num[0]','$Lastloginscreen60Num[0]',
                          '$Lastloginscreen71Num[0]','$Lastloginscreen72Num[0]','$Lastloginscreen73Num[0]','$Lastloginscreen80Num[0]',
                          '$weekPayARPU[0]','$weekActiveARPU[0]','$weekLogARPU[0]','$weekWastageRate[0]','$weekPayRate[0]','$weekLogPayRate[0]','$weekPayWastageRate[0]',
                          '$weekPayPesonrTime[0]','$Level[0]','$newPayPesonrNum','$paytimes[0]','$PayPesonrNum[0]',
                          '$iap1[0]','$iap2[0]','$iap3[0]','$iap4[0]','$iap5[0]','$iap6[0]','$iap7[0]','$iap8[0]','$iap9[0]','$iap10[0]','$iap11[0]','$iap12[0]','$iap13[0]','$iap14[0]','$iap15[0]','$iap16[0]',
                          '$totalTodayGameTime[0]',
                          '$weekOneLandPesonrNum','$WeekNewPayPesonrNum[0]','$MonthLandTwicePesonrNum','$WeekPayRechargeNum[0]','$dayRechargeNum[0]')";
$query= @mysql_query($sql,$connection) or die(mysql_error());  

}
?>
